package net.oschina.app;

import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;

import com.robotium.solo.Solo;

/**
 * Created by Aaron on 2017/10/29.
 */

public class BasicTestCase extends ActivityInstrumentationTestCase2<AppStart> {
    private Solo solo;
    private SoloWrap soloWrap;
    public Helper helper;

    public BasicTestCase(){
        super(AppStart.class);
    }

    @Override
    public void setUp() throws Exception {
        try{
            super.setUp();
            solo = new Solo(getInstrumentation(),getActivity());
            soloWrap = new SoloWrap(solo);
            helper = new Helper(soloWrap);
            helper.getPageCommon().goToMySettingsTab();
            if(helper.getPageCommon().searchText("aotu12345aotu")){
                helper.getPageMySettings().clickSettingsBtn();
                helper.getPageSettings().clickLogout();
            }
            helper.getPageCommon().goToHomeTab();
        }catch (Exception ex){
             tearDown();
             throw ex;
        }

    }

    @Override
    protected void runTest() throws Throwable {
        try{
            super.runTest();
        }catch (Throwable thr){
            throw thr;
        }

    }

    @Override
    public void tearDown() throws Exception {
        try{

        }catch (Throwable thr){

        }finally {
            solo.finishOpenedActivities();
            super.tearDown();
        }

    }
}
